package com.ysu.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysu.shop.pojo.Orderdetail;
import com.ysu.shop.mapper.OrderdetailMapper;
import com.ysu.shop.service.IOrderdetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysu.shop.utils.InitUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 霍京
 * @since 2021-3-03
 */
@Service
public class OrderdetailServiceImpl extends ServiceImpl<OrderdetailMapper, Orderdetail> implements IOrderdetailService {

    @Resource
    private OrderdetailMapper orderdetailMapper;

    @Override
    public int send(int id) {
        return orderdetailMapper.send(id);
    }

    @Override
    public int receive(int id) {
        return orderdetailMapper.receive(id);
    }

    @Override
    public IPage<Map<String, Object>> getOrderItem(Map<String,Object> param,int id) {
        QueryWrapper<Orderdetail> wrapper = new QueryWrapper<>();
        InitUtil.initPage(param);
        int num = Integer.parseInt(param.get("page").toString());
        int limit = Integer.parseInt(param.get("limit").toString());
        InitUtil.initEq(param, wrapper, "product_name","status");
        IPage<Orderdetail> page = new Page<>(num, limit);
        return orderdetailMapper.getOrderItem(page,id,wrapper);
    }
}
